<?php

namespace app\common\model;

use think\Model;


class Balercheck extends Model
{

    

    

    // 表名
    protected $name = 'balercheck';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'yyy_status_text',
        'dbs_status_text',
        'rhy_status_text'
    ];
    

    
    public function getYyyStatusList()
    {
        return ['1' => __('Yyy_status 1'), '2' => __('Yyy_status 2')];
    }

    public function getDbsStatusList()
    {
        return ['1' => __('Dbs_status 1'), '2' => __('Dbs_status 2')];
    }

    public function getRhyStatusList()
    {
        return ['1' => __('Rhy_status 1'), '2' => __('Rhy_status 2')];
    }


    public function getYyyStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['yyy_status']) ? $data['yyy_status'] : '');
        $list = $this->getYyyStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDbsStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['dbs_status']) ? $data['dbs_status'] : '');
        $list = $this->getDbsStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRhyStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['rhy_status']) ? $data['rhy_status'] : '');
        $list = $this->getRhyStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('Admin', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function stand()
    {
        return $this->belongsTo('Stand', 'stand_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
